﻿namespace IPMS.BLL
{
    using IPMS.DAL;
    using System;
    using System.Data;
    using System.Data.SqlClient;

    public class HeadingTmplts
    {
        private string _HeadingCode;
        private string _HeadingDescription;
        private string _HeadingName;
        private string _HeadingNameChinese;
        private string _Section;

        public int GetHeadingTmpltInfo(string headingCode, string section)
        {
            SqlCommand sqlCmd = new SqlCommand();
            DataAccessLayer DAL = new DataAccessLayer();
            DAL.AddParamToSQLCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);
            DAL.AddParamToSQLCmd(sqlCmd, "@HeadingCode", SqlDbType.NVarChar, 30, ParameterDirection.Input, headingCode);
           // DAL.AddParamToSQLCmd(sqlCmd, "@Section", SqlDbType.NVarChar, 30, ParameterDirection.Input, section);
            DAL.AddParamToSQLCmd(sqlCmd, "@HeadingName", SqlDbType.NVarChar, 100, ParameterDirection.Output, null);
            DAL.AddParamToSQLCmd(sqlCmd, "@HeadingNameChinese", SqlDbType.NVarChar, 100, ParameterDirection.Output, null);
            DAL.AddParamToSQLCmd(sqlCmd, "@HeadingDescription", SqlDbType.NVarChar, 100, ParameterDirection.Output, null);
            DAL.AddParamToSQLCmd(sqlCmd, "@Section", SqlDbType.NVarChar, 30, ParameterDirection.Input, section);
            DAL.SetCommandType(sqlCmd, CommandType.StoredProcedure, "RetrieveHeadingTemplateSp");
            DAL.ExecuteScalarCmd(sqlCmd);
            int resultValue = (int) sqlCmd.Parameters["@ReturnValue"].Value;
            this._HeadingName = (string) sqlCmd.Parameters["@HeadingName"].Value;
            this._HeadingNameChinese = (string) sqlCmd.Parameters["@HeadingNameChinese"].Value;
            this._HeadingDescription = (string) sqlCmd.Parameters["@HeadingDescription"].Value;
            this._Section = section;
            return resultValue;
        }

        public int GetHeadingTmpltInfo(string headingCode)
        {
            SqlCommand sqlCmd = new SqlCommand();
            DataAccessLayer DAL = new DataAccessLayer();
            DAL.AddParamToSQLCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);
            DAL.AddParamToSQLCmd(sqlCmd, "@HeadingCode", SqlDbType.NVarChar, 30, ParameterDirection.Input, headingCode);
            DAL.AddParamToSQLCmd(sqlCmd, "@HeadingName", SqlDbType.NVarChar, 100, ParameterDirection.Output, null);
            DAL.AddParamToSQLCmd(sqlCmd, "@HeadingNameChinese", SqlDbType.NVarChar, 100, ParameterDirection.Output, null);
            DAL.AddParamToSQLCmd(sqlCmd, "@HeadingDescription", SqlDbType.NVarChar, 100, ParameterDirection.Output, null);
            DAL.AddParamToSQLCmd(sqlCmd, "@Section", SqlDbType.NVarChar, 30, ParameterDirection.Output, null);
            DAL.SetCommandType(sqlCmd, CommandType.StoredProcedure, "RetrieveHeadingTemplateSp");
            DAL.ExecuteScalarCmd(sqlCmd);
            int resultValue = (int)sqlCmd.Parameters["@ReturnValue"].Value;
            this._HeadingName = (string)sqlCmd.Parameters["@HeadingName"].Value;
            this._HeadingNameChinese = (string)sqlCmd.Parameters["@HeadingNameChinese"].Value;
            this._HeadingDescription = (string)sqlCmd.Parameters["@HeadingDescription"].Value;
            this._Section = (string)sqlCmd.Parameters["@Section"].Value;
            return resultValue;
        }

        public string HeadingDescription
        {
            get
            {
                return this._HeadingDescription;
            }
        }

        public string HeadingName
        {
            get
            {
                return this._HeadingName;
            }
        }

        public string HeadingNameChinese
        {
            get
            {
                return this._HeadingNameChinese;
            }
        }

        public string Section
        {
            get
            {
                return this._Section;
            }
        }
    }
}

